BatchToSpaceND ================= 将输入张量的 batch 维度按 block 因子分解并重排到空间维度,随后根据 ``crops`` 参数对输出空间范围进行裁剪。 - 输入形状: ``[batch, height, width, channel]`` - ``block_size``: ``[block_h, block_w]`` - ``crops``: ``[top, bottom, left, right]`` 输入: - **input** - 输入数据地址。 - **input_shape** - 输入形状,格式为 ``[batch, height, width, channel]``。 - **block_size** - 分块因子,格式为 ``[block_h, block_w]``。 - **crops** - 裁剪参数,格式为 ``[top, bottom, left, right]``。 - **core_mask(int, 可选)** - 核掩码(仅适用于共享存储版本)。 输出: - **output** - 输出数据地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持的数据类型: fp32、fp64、cplx64、cplx128、int16、int8、int32。 - MT7004 支持的数据类型: fp32、fp16、cplx64、int16、int32。 **共享存储版本:** .. c:function:: void i8_batch_to_space_nd_s(int8_t *input, int8_t *output, const int *input_shape, const int *block_size, const int *crops, int core_mask) .. c:function:: void i16_batch_to_space_nd_s(int16_t *input, int16_t *output, const int *input_shape, const int *block_size, const int *crops, int core_mask) .. c:function:: void i32_batch_to_space_nd_s(int32_t *input, int32_t *output, const int *input_shape, const int *block_size, const int *crops, int core_mask) .. c:function:: void hp_batch_to_space_nd_s(float16 *input, float16 *output, const int *input_shape, const int *block_size, const int *crops, int core_mask) .. c:function:: void fp_batch_to_space_nd_s(float *input, float *output, const int *input_shape, const int *block_size, const int *crops, int core_mask) .. c:function:: void dp_batch_to_space_nd_s(double *input, double *output, const int *input_shape, const int *block_size, const int *crops, int core_mask) .. c:function:: void c64_batch_to_space_nd_s(float *input, float *output, const int *input_shape, const int *block_size, const int *crops, int core_mask) .. c:function:: void c128_batch_to_space_nd_s(double *input, double *output, const int *input_shape, const int *block_size, const int *crops, int core_mask) **C 调用示例:** .. code-block:: c :linenos: :emphasize-lines: 11 // MT7004 示例(共享存储多核,DDR 地址) #include int main(int argc, char *argv[]) { float *input = (float *)0x81000000; float *output = (float *)0x82000000; int input_shape[4] = {400, 2, 2, 3}; int block_size[2] = {2, 2}; int crops[4] = {0, 0, 0, 0}; int core_mask = 0xff; fp_batch_to_space_nd_s(input, output, input_shape, block_size, crops, core_mask); return 0; } **私有存储版本:** .. c:function:: void i8_batch_to_space_nd_p(int8_t *input, int8_t *output, const int *input_shape, const int *block_size, const int *crops) .. c:function:: void i16_batch_to_space_nd_p(int16_t *input, int16_t *output, const int *input_shape, const int *block_size, const int *crops) .. c:function:: void i32_batch_to_space_nd_p(int32_t *input, int32_t *output, const int *input_shape, const int *block_size, const int *crops) .. c:function:: void hp_batch_to_space_nd_p(float16 *input, float16 *output, const int *input_shape, const int *block_size, const int *crops) .. c:function:: void fp_batch_to_space_nd_p(float *input, float *output, const int *input_shape, const int *block_size, const int *crops) .. c:function:: void dp_batch_to_space_nd_p(double *input, double *output, const int *input_shape, const int *block_size, const int *crops) .. c:function:: void c64_batch_to_space_nd_p(float *input, float *output, const int *input_shape, const int *block_size, const int *crops) .. c:function:: void c128_batch_to_space_nd_p(double *input, double *output, const int *input_shape, const int *block_size, const int *crops) **C 调用示例:** .. code-block:: c :linenos: :emphasize-lines: 10 // MT7004 示例(私有存储单核,AM 地址) #include int main(int argc, char *argv[]) { float *input = (float *)0x10000000; float *output = (float *)0x10020000; int input_shape[4] = {400, 2, 2, 3}; int block_size[2] = {2, 2}; int crops[4] = {0, 0, 0, 0}; fp_batch_to_space_nd_p(input, output, input_shape, block_size, crops); return 0; }